import { QueryClient, useMutation } from "@tanstack/react-query";
import { useForm } from "react-hook-form";
import { AxiosError } from "axios";
import { ModelFileService } from "@/shared/api/api.model-file";
import { ImageFileService } from "@/shared/api/api.image-file";
import { ImageServise } from "@/shared/api/api.image";
import { IImageDto } from "@/shared/interfaces";

export function useCreateImage() {

    const queryClient = new QueryClient

    const createImageMut = useMutation(
        {
            mutationFn: ImageServise.create,
            onError: (error: (AxiosError<{ message: string }>)) => error,
        }, queryClient
    );
    const isError = createImageMut.isError;

    return {
        isError,
        response: createImageMut.data,
        isPending: createImageMut.isPending,
        isSuccess: createImageMut.isSuccess,
        handleMutate: (data: IImageDto) => createImageMut.mutate({ ...data }),
    };
}